package com.skyolder.milkbee.domain;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import javax.persistence.*;
import java.io.Serializable;
import java.time.ZonedDateTime;
import java.util.Objects;

/**
 * A Award.奖品
 * name 名称
 * detail 详情
 * rank 奖品等级
 * sweepstakeId 抽奖活动ID
 * quantum 数量
 * photograph 图片地址
 * createdAt 创建时间
 * userId 用户ID
 * leaguerId 会员ID
 */
@Entity
@Table(name = "award")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class Award implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    @Column(name = "name")
    private String name;

    @Column(name = "detail")
    private String detail;

    @Column(name = "rank")
    private Integer rank;

    @Column(name = "sweepstake_id")
    private Long sweepstakeId;

    @Column(name = "quantum")
    private Integer quantum;

    @Column(name = "photograph")
    private String photograph;

    @Column(name = "created_at")
    private ZonedDateTime createdAt;

    @Column(name = "user_id")
    private Long userId;

    @Column(name = "leaguer_id")
    private Long leaguerId;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public Award name(String name) {
        this.name = name;
        return this;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDetail() {
        return detail;
    }

    public Award detail(String detail) {
        this.detail = detail;
        return this;
    }

    public void setDetail(String detail) {
        this.detail = detail;
    }

    public Integer getRank() {
        return rank;
    }

    public Award rank(Integer rank) {
        this.rank = rank;
        return this;
    }

    public void setRank(Integer rank) {
        this.rank = rank;
    }

    public Long getSweepstakeId() {
        return sweepstakeId;
    }

    public Award sweepstakeId(Long sweepstakeId) {
        this.sweepstakeId = sweepstakeId;
        return this;
    }

    public void setSweepstakeId(Long sweepstakeId) {
        this.sweepstakeId = sweepstakeId;
    }

    public Integer getQuantum() {
        return quantum;
    }

    public Award quantum(Integer quantum) {
        this.quantum = quantum;
        return this;
    }

    public void setQuantum(Integer quantum) {
        this.quantum = quantum;
    }

    public String getPhotograph() {
        return photograph;
    }

    public Award photograph(String photograph) {
        this.photograph = photograph;
        return this;
    }

    public void setPhotograph(String photograph) {
        this.photograph = photograph;
    }

    public ZonedDateTime getCreatedAt() {
        return createdAt;
    }

    public Award createdAt(ZonedDateTime createdAt) {
        this.createdAt = createdAt;
        return this;
    }

    public void setCreatedAt(ZonedDateTime createdAt) {
        this.createdAt = createdAt;
    }

    public Long getUserId() {
        return userId;
    }

    public Award userId(Long userId) {
        this.userId = userId;
        return this;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public Long getLeaguerId() {
        return leaguerId;
    }

    public Award leaguerId(Long leaguerId) {
        this.leaguerId = leaguerId;
        return this;
    }

    public void setLeaguerId(Long leaguerId) {
        this.leaguerId = leaguerId;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Award award = (Award) o;
        if (award.id == null || id == null) {
            return false;
        }
        return Objects.equals(id, award.id);
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(id);
    }

    @Override
    public String toString() {
        return "Award{" +
            "id=" + id +
            ", name='" + name + "'" +
            ", detail='" + detail + "'" +
            ", rank='" + rank + "'" +
            ", sweepstakeId='" + sweepstakeId + "'" +
            ", quantum='" + quantum + "'" +
            ", photograph='" + photograph + "'" +
            ", createdAt='" + createdAt + "'" +
            ", userId='" + userId + "'" +
            ", leaguerId='" + leaguerId + "'" +
            '}';
    }
}
